//
//  GHSAlertView_FH.m
//  penzer
//
//  Created by 还带大道 on 2018/11/16.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "GHSAlertView_FH.h"

@interface GHSAlertView_FH()
@property (weak, nonatomic) IBOutlet UIView *bgV;
@property (weak, nonatomic) IBOutlet UIView *textV;
@property (weak, nonatomic) IBOutlet UITextField *textFiled;
@property (weak, nonatomic) IBOutlet UIButton *takePhotoBtn;
@property (weak, nonatomic) IBOutlet UIButton *promitBtn;
@property (weak, nonatomic) IBOutlet UIView *contentV;
@property (nonatomic,strong) CAGradientLayer *gl;

@end

@implementation GHSAlertView_FH


+ (instancetype)shareView
{
    return [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil].lastObject;
}


- (void)awakeFromNib
{
    [super awakeFromNib];
    self.backgroundColor = [UIColor clearColor];
    _bgV.backgroundColor = RZ_COLOR_ALPHA(0, 0, 0, 0.6);
    _contentV.backgroundColor = [UIColor whiteColor];
    _contentV.layer.cornerRadius = 5;
    _textV.layer.cornerRadius = 2;
    _textV.layer.borderColor = RZ_COLOR(220, 220, 220).CGColor;
    _textV.layer.borderWidth = 1;
    
    //
    self.takePhotoBtn.backgroundColor = [UIColor whiteColor];
    [self.takePhotoBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap)];
    [self.contentV addGestureRecognizer:tap];
    
    //渐变背景色
    self.promitBtn.backgroundColor = [UIColor clearColor];
//    [self.promitBtn setBackgroundImage:[UIImage imageNamed:@"按钮3"] forState:UIControlStateNormal];
    CAGradientLayer *gl = [CAGradientLayer layer];
    _gl = gl;
    gl.startPoint = CGPointMake(0, 0);
    gl.endPoint = CGPointMake(1, 1);
    gl.colors = @[(__bridge id)RZ_COLOR(48, 35, 174).CGColor,(__bridge id)RZ_COLOR(200, 109, 215).CGColor];
    gl.locations = @[@(0),@(1.0f)];
    [self.promitBtn.layer addSublayer:gl];
}



- (void)layoutSubviews
{
    [super layoutSubviews];
    [self.promitBtn layoutIfNeeded];
    _gl.frame = self.promitBtn.layer.bounds;
    _gl.cornerRadius = _gl.frame.size.height*0.5;
}


- (IBAction)takPhoto {
    
}

- (IBAction)promit {
    [self removeFromSuperview];
}


- (void)tap
{
    [self endEditing:YES];
}
@end
